//
// Copyright (c) 2009 All Right Reserved
//
// vl
//
// 2009-01-01
// Contains ...
namespace LargoCommon.Music
{
using Abstract;
using JetBrains.Annotations;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Text;
/// Musical material.
/// Musical class.
//// [Serializable]
[ContractVerification(false)]
public sealed class HarmonicMaterial {
#region Constructors
///
/// Initializes a new instance of the HarmonicMaterial class.
///
public HarmonicMaterial() {
this.Structures = new List();
}
#endregion
#region Properties
///
/// Gets or sets the name.
///
///
/// The melodic order.
///
public string Name { [UsedImplicitly] get; set; }
///
/// Gets or sets the harmonic order.
///
/// The harmonic order.
public byte HarmonicOrder { [UsedImplicitly] get; set; }
///
/// Gets the structures.
///
///
/// The structures.
///
public IList Structures { get; }
#endregion
#region HarmonicProducer
///
/// Random Harmonic Material.
///
/// Number of material sets.
/// Harmonic structures.
/// Number Of Structs.
///
/// Returns value.
///
[UsedImplicitly]
public static Collection RandomHarmonicMaterials(int number, Collection harmonicStructs, int numberOfStructs) { //// byte harmonicOrder,
Contract.Requires(harmonicStructs != null);
var coll = new Collection();
for (var i = 0; i < number; i++) {
var name = string.Format(CultureInfo.CurrentCulture, "Automatic ({0}) {1}", i.ToString(CultureInfo.CurrentCulture.NumberFormat).PadLeft(3), SupportCommon.DateTimeIdentifier);
var harMaterial = RandomHarmonicMaterial(name, harmonicStructs, numberOfStructs);
coll.Add(harMaterial);
}
return coll;
}
#endregion
#region String representation
/// String representation of the object.
/// Returns value.
public override string ToString() {
var s = new StringBuilder();
//// s.Append("\t" + this.RhythmicOrder.ToString(CultureInfo.CurrentCulture));
return s.ToString();
}
#endregion
#region HarmonicProducer - private
///
/// Random Harmonic Material.
///
/// Name of material.
/// Harmonic structures.
/// Number Structs.
///
/// Returns value.
///
private static HarmonicMaterial RandomHarmonicMaterial(string name, Collection harStructs, int numberStructs) {
Contract.Requires(name != null);
Contract.Requires(harStructs != null);
//// var dc = this.GetDataContext;
var harMaterial = new HarmonicMaterial { Name = name };
//// HarmonicSystem harSystem = HarmonicSystem.GetHarmonicSystem(harmonicOrder);
for (var im = 0; im < numberStructs; im++) {
var hs = ExtendCollection.GetRandomObject(harStructs);
if (hs == null || harMaterial.Structures == null) {
continue;
}
var mhs = hs; //// Clone()
harMaterial.Structures.Add(mhs);
}
return harMaterial;
}
#endregion
}
}